SUM 解决方案
-
算出
orders
表格中的
poster_qty
纸张总订单量。
SELECT SUM(poster_qty) AS total_poster_sales
FROM orders;
-
算出
orders
表格中
standard_qty
纸张的总订单量。
SELECT SUM(standard_qty) AS total_standard_sales
FROM orders;
-
根据
orders
表格中的
total_amt_usd
得出总销售额。
SELECT SUM(total_amt_usd) AS total_dollar_sales
FROM orders;
-
算出 orders 表格中每个订单在
standard
和
gloss
纸张上消费的数额。结果应该是表格中每个订单的金额。
注意,此解决方案没有使用聚合函数
。
SELECT standard_qty + gloss_qty AS total_standard_gloss
FROM orders;
-
每个订单的
price/standard_qty
纸张各不相同。我想得出
orders
表格中每个销售机会的这一比例。
注意,此解决方案使用了聚合函数和数学运算符
SELECT SUM(standard_amt_usd)/SUM(standard_qty) AS standard_price_per_unit
FROM orders;